<?php
function form_insert_post_type(){
	$prefix = "jamnews";
	// Tab labels
	$tab_labels = array(
		'general' 	=> __('General','jamnews')
	);
	
	// Tabs fields
	$tab_fields = array(
		'general' => array(
			array(	'title' => 'Basic Options', 
					'type' => 'title' ),
					
			array( 	'name' => 'post_type',
					'title' => __('Post type','jamnews'),
					'type' => 'text',
					'id' => 'post_type',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('Max. 20 characters, can not contain capital letters or spaces','jamnews') ),
				   
			array( 	'name' =>  'label',
					'title' => __('Label','jamnews'),
					'type' => 'text',
					'id' => 'label',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' =>  __('A plural descriptive name for the post type marked for translation.','jamnews') ),
			
			array( 	'name' => 'description',
					'title' =>	__('Description','jamnews'),
					'type' => 'textarea',
					'id' => 'description',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' =>  __('A short descriptive summary of what the post type is.','jamnews')),
					
			array(	'name' 		=> 'supports[title]',
					'title' 	=> __( 'Supports', 'jamnews' ),
					'desc' 		=> __( '\'Title\'', 'jamnews' ),
					'id' 		=> 'supports_title',
					'default'	=> 'yes',
					'type' 		=> 'checkbox',
					'checkboxgroup'	=> 'start' ),
			
			array(	'name' 		=> 'supports[editor]',
					'desc' 		=> __( '\'Editor\' (content) ', 'jamnews' ),
					'id' 		=> 'supports_editor',
					'default'	=> 'yes',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name' 		=> 'supports[author]',
					'desc' 		=> __( '\'Author\'', 'jamnews' ),
					'id' 		=> 'supports_author',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name' 		=> 'supports[thumbnail]',
					'desc' 		=> __( '\'Thumbnail\' (featured image, current theme must also support <a target="_blank" href="http://codex.wordpress.org/Post_Thumbnails">post-thumbnails</a>) ', 'jamnews' ),
					'id' 		=> 'supports_thumbnail',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[excerpt]',
					'desc' 		=> __( '\'Excerpt\'', 'jamnews' ),
					'id' 		=> 'supports_excerpt',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[trackbacks]',
					'desc' 		=> __( '\'Trackbacks\'', 'jamnews' ),
					'id' 		=> 'supports_trackbacks',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[custom-fields]',
					'desc' 		=> __( '\'Custom fields\'', 'jamnews' ) ,
					'id' 		=> 'supports_custom-fields',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[comments]',
					'desc' 		=> __( '\'Comments\' (also will see comment count balloon on edit screen) ', 'jamnews' ),
					'id' 		=> 'supports_comments',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[revisions]',
					'desc' 		=> __( '\'Revisions\' (will store revisions) ', 'jamnews' ),
					'id' 		=> 'supports_revisions',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'	=> 'supports[page-attributes]',
					'desc' 		=> __( '\'Page Attributes\' (menu order, hierarchical must be true to show Parent option) ', 'jamnews' ),
					'id' 		=> 'supports_page-attributes',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=>	'supports[post-formats]',
					'desc' 		=> __( '\'Post Formats\' add post formats, see <a href="http://codex.wordpress.org/Post_Formats">Post Formats</a>', 'jamnews' ),
					'id' 		=> 'supports_post-formats',
					'default'	=> 'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'title'		=> 'Taxonomies',
					'desc' 		=> __('<i> An array of registered taxonomies like category or post_tag that will be used with this post type.</i>', 'jamnews' ),
					'desc_tip'	=> true,
					'id' 		=> 'taxonomies',
					'name' 		=> 'taxonomies',
					'class'		=> 'span5 chosen_select',
					'type' 		=> 'multiselect',
					'options'	=> get_taxonomies() ),
				   
			array( 'type' => 'sectionend')
		)
	);		
	?>
	<div class="wrap jamnews">
		<div id="icon-edit" class="icon32 icon32-posts-post"><br /></div>
		<h2>
			<?php echo __("Add New Post Types",'jamnews');?>
		</h2>
		
		<form method="post" id="addform" action="" enctype="multipart/form-data">
			<?php wp_nonce_field( 'jamnews_admin_save_posttype', '_wpnonce', true, true ); ?>
			<div id="poststuff">
				<div id="post-body-content">
					<!-- Begin tab -->
					<ul class="nav nav-tabs">
					<?php $count = 0; foreach($tab_labels as $key => $value){ ?>
						<li <?php echo ($count==0?" class='active'":"")?>>
							<a href="#<?php echo $key; ?>" data-toggle="tab"><?php echo $value; ?></a>
						</li>
					<?php $count++; } ?>
					</ul>
					<div class="tab-content">
						<?php $count = 0; foreach($tab_fields as $key => $tab_content){ ?>
						<div class="tab-pane<?php echo ($count==0?" active":"");?>" id="<?php echo $key;?>">
							<?php jamnews_admin_fields($tab_content)?>
						</div>
						<?php $count++; } ?>
					</div>
					<!-- End tab-content -->
					<br/>
					<div class="button-group">
						<input type="submit" name="btn-add-post-type" class="btn" value="<?php echo __("Add New","jamnews")?>" />
					</div>
				</div>
			</div>
		</form>
	</div>
	<script>
	jQuery(function($){
		// Validate form add new post type
		$("#addform").validate({
			rules: {
				post_type: {
					required: true,
					minlength: 3,
				}
			},
			messages: {
				post_type: {
					required: "The 'Post type' is required.",
					minlength: "The 'Post type' must be more than 3 characters.",
				},
			},
		});
	});
	</script>
	<?php
}
?>